package com.yu.rpc.core.server;

import io.vertx.core.AsyncResult;
import io.vertx.core.Vertx;

public class VertHttpServer implements HttpServer {

    @Override
    public void doStart(int port) {
        Vertx.vertx().createHttpServer()
                .requestHandler(new HttpServerHandler())
                .listen(port, result -> handleListener(port, result));
    }

    private void handleListener(int port, AsyncResult<io.vertx.core.http.HttpServer> result) {
        if (result.succeeded()) {
            System.out.println("server started on port " + port);
        } else {
            System.out.println("server start failed");
        }
    }
}
